#include "tower.h"
#include <cassert>

Tower::Tower(float x, float y, float s) :
    Shape(x,y)
{
    targets[0] = Target(x, y, s, s);
    targets[1] = Target(x + s, y, s, s);
    targets[2] = Target(x, y + s, s, s);
    targets[3] = Target(x + s, y + s, s, s);
    targets[4] = Target(x, y + (s*2), s, s);
    targets[5] = Target(x + s, y + (s*2), s, s);
    targets[6] = Target(x, y + (s*3), s, s);
    targets[7] = Target(x + s, y + (s*3), s, s);
    targets[8] = Target(x - (s*0.7), y + (s*4), s, s);
    targets[9] = Target(x + (s*0.5), y + (s*4), s, s);
    targets[10] = Target(x + (s*1.7), y + (s*4), s, s);
}

Tower::~Tower(){
}

Target& Tower::getTarget(const unsigned index)
{
    assert(index <= 11);
    return targets[index];
}

bool Tower::everthingDead() const
{
    for(unsigned i = 0; i<= 10; ++i)
    {
        if(targets[i].health() > 0)
            return false;
    }
    return true;
}

void Tower::reset()
{
    for(unsigned i = 0; i <= 11; ++i)
    {
        targets[i].resetHealth();
    }
    assert(!everthingDead());
}

